<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 100px;
            height: 100px;
            background-color: crimson;
            position: absolute;
            top: 0px;
            left: 0px;
        }
    </style>
</head>
<body>
    <div>

    </div>
    <script>
        function move(ele,dir,target,fn){
            var timer = setInterval(function(){
                var num = parseInt(getComputedStyle(ele)[dir]);
                if ( num == target ){
                    clearTimeout(timer);
                    fn && fn();
                } else {
                    num += 10 ;
                    ele.style[dir] = num + 'px' ; 
                }
            }, 100);
        }
        var divEle = document.querySelector("div");
        move(divEle,'left',400,function(){
            move(divEle,'top',700);
        });
    </script>
</body>
</html>